package leetcode.median;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * ClassName: $406_QueueReconstructionbyHeight
 * Description:
 * date: 2021-10-18 20:57
 *
 * @author liyifan
 */
public class $406_QueueReconstructionbyHeight {
    public int[][] reconstructQueue(int[][] people) {
        Arrays.sort(people, (o1, o2) -> {
            if (o1[0] != o2[0])
                return Integer.compare(o2[0], o1[0]);
            else
                return Integer.compare(o1[1], o2[1]);
        });
        List<int[]> res = new ArrayList<>();
        for (int[] p:people) {
            res.add(p[1], p);
        }
        return res.toArray(new int[res.size()][]);
    }
}
